package com.hgw.Demo07_ObserverPattern.Exercises22_9_5;

import java.util.ArrayList;

/**
 * Data time:2021/12/19 17:55
 * StudentID:2019112118
 * Author:hgw
 * Description: 二级学院（系），充当目标
 */
public abstract class AbstractDepartment {
    protected String departmentName;  // 战队名称
    protected ArrayList<People> peoples = new ArrayList<People>();

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    // 注册方法
    public void attach(People obs) {
        System.out.println(obs.getName() + "录取入：" + this.getDepartmentName());
        peoples.add(obs);
    }

    // 注销方法
    public void detach(People obs) {
        System.out.println(obs.getName() + "毕业于：" + this.getDepartmentName());
        peoples.remove(obs);
    }

    // 声明抽象通知方法
    public abstract void notifyPeople(String name);
}
